/*
 * @Author: YeMiao 
 * @Date: 2018-02-23 17:25:31 
 * @Last Modified by:   YeMiao 
 * @Last Modified time: 2018-02-23 17:25:31 
 */

import { Injectable }     from '@angular/core';
import { CanActivate, Router, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';

@Injectable()
export class AuthGuard implements CanActivate {

  constructor( private router: Router){
  }

  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
    if(sessionStorage.getItem('user') != null){
      return true;
    }else{
      this.router.navigate(['login']);
      return false;
    }
  }


}